package lzzy12;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class TextStudent {
    public static void main(String[] args) {
        Student stu1=new Student("1","大哥",78.58);
        Student stu2=new Student("2","二哥",92.59);
        Student stu3=new Student("3","大嫂",60.50);
        ArrayList<Student> list=new ArrayList<>();
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        list.sort(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.score<o2.score ? 1 : o1.score==o2.score ? 0: -1;
            }
        });
        System.out.println("排序后： ");
        for (Student stu :list){
            System.out.println(stu);
        }
        Student max= Collections.max(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.score> o2.score? 1 : o1.score==o2.score ? 0 : -1;
            }
        });
        System.out.println("成绩最大"+max);
        Student min=Collections.max(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.score<o2.score ? 1 : o1.score== o2.score ? 0 :-1;
            }
        });
        System.out.println("成绩最小"+min);
    }
}
